
export function cutstr(str, len) {
	var str_length = 0;
	var str_len = 0;
	let str_cut = new String();
	str_len = str?str.length:0;
	for (var i = 0; i < str_len; i++) {
		var a = str.charAt(i);
		str_length++;
		if (escape(a).length > 4) {
			//中文字符的长度经编码之后大于4
			str_length++;
		}
		str_cut = str_cut.concat(a);
		if (str_length >= len) {
			str_cut = str_cut.concat("...");
			return str_cut;
		}
	}
	//给定字符串小于指定长度时，则返回源字符串；
	if (str_length < len) {
		return str;
	}
}
